/**
 * Created by jondai on 2018/3/21.
 */
var TrainExcellentPointRepeat = {
    TrainExcellentPointRepeat : {}
};

layui.use('table', function(){
    var table = layui.table;
    var repeat = JSON.parse($("#repeat").val());
    debugger
    //展示已知数据
    table.render({
        elem: '#demo1',
        id: 'demo1'
        ,cols: [[ //标题栏
            {type:'checkbox'},
            {title: '年度', field: 'year',event: 'setEmpCode', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '员工姓名', field: 'empName',event: 'setEmpCode', visible: true, align: 'center', valign: 'middle', sortable: true},
            {title: '员工编号', field: 'empCode', visible: true, align: 'center', event: 'setEmpCode', style:'cursor: pointer;'},
            {title: '岗位类别', field: 'postType',event: 'setEmpCode', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '专业', field: 'major',event: 'setEmpCode', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '获奖级别', field: 'authen',event: 'setEmpCode', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '发证机关', field: 'issuingOrgan',event: 'setEmpCode', visible: false, align: 'center', valign: 'middle',sortable: true},
            {title: '发证时间', field: 'issuingDate',event: 'setEmpCode', visible: true, align: 'center', valign: 'middle',sortable: true},
        ]]
        ,data: repeat
        ,page: true
        ,limits:[100]
        ,limit:100
        ,even: true
    });

    //监听单元格事件
    table.on('tool(demoEvent1)', function(obj) {
        debugger
        var data = obj.data;
        var url = Feng.ctxPath + '/employee/select_list?empName='+data.empName;
        if (obj.event === 'setEmpCode') {
            layer.open({
                type: 2,
                area: ['800px', '500px'],
                fixed: false, //不固定
                maxmin: true,
                content:url,
                btn: ['确定'],
                yes: function(index, layero){
                    var res = window["layui-layer-iframe" + index].Employee.callbackdata();
                    debugger
                    obj.update({
                        empCode: res.empCode
                    });
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                }
            });
        }
    });

    TrainExcellentPointRepeat.getContestDatas = function() {
        var checkStatus = table.checkStatus('demo1');
        return checkStatus.data;
    }
});